﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using DICE_GS;

public class Popup_DailyMissionList : Popup
{
    static public bool s_IsShow = false; // 게임에서 딱한번만 뜨게 해주는 변수    
   
    // 업적셀 갯수
    static DailyMissionListCell[] s_DailyMissionCellList;

    public override void AwakeInit()
    {
        CreateDailyMissionListCells();
        LTDefine.SetAllChildTransformLayer(transform, LayerMask.NameToLayer("GUI_TOP"));
        gameObject.SetActive(true);

        //transform.localScale = Vector3.one / 10;
        //iTween.ScaleTo(gameObject, iTween.Hash("easetype", "spring", "islocal", true, "time", 0.5f, "scale", Vector3.one, "oncompletetarget", gameObject, "oncomplete", "Showcomplte"));
    }

    void CreateDailyMissionListCells()
    {
        //IDictionary<int, CAchievementData>  AchievementDataDic = CAchievementDataManager.Instance.GetAchievementMap();


        if (s_DailyMissionCellList == null)
            s_DailyMissionCellList = new DailyMissionListCell[MyInfo.Instance.MissionCount];

        Transform scrollPanelTransform = transform.FindChild("Body").FindChild("Panel");
        UIScrollView scrollView = scrollPanelTransform.GetComponent("UIScrollView") as UIScrollView;
        Transform GridTransform = scrollPanelTransform.FindChild("Grid");

        for (int i = 0; i < s_DailyMissionCellList.Length; i++)
        {
            if (s_DailyMissionCellList[i] == null)
                s_DailyMissionCellList[i] = DailyMissionListCell.SetCell(i, GridTransform, scrollView);

            s_DailyMissionCellList[i].SetCellWithMissionID(MyInfo.Instance.DailyMissionIDList[i], i);   // 재사용 가능 구조
        }
    }
}
